<?php

namespace app\admin\model;

use think\Model;

class apower extends Model
{
    public static function getDatas()
    {
        $list = self::order('weight asc')
            ->order('weight asc')
            ->column('powerid,columnid,powername,controller,class,type,status,describe,weight');
        return $list;
    }

    public static function apowerAdd($data)
    {
        $id = self::field('powerid,columnid,powername,controller,class,type,status,describe,weight')->insertGetId($data);
        if(!$id) throw new \Exception('添加节点失败');

        return $id;
    }

    public static function apowerUpdate($data)
    {
        $id = $data['powerid'];
        $result = self::field('powerid,columnid,powername,controller,class,type,status,describe,weight')->update($data);
        if(!$result) throw new \Exception('修改节点失败');
        return $id;
    }

    public static function apowerDel($where)
    {
        $result = self::where($where)->delete();
        if(!$result) throw new \Exception('删除节点失败');
    }
}